ZHONGLANGDB_CONN = "";
function getZhongLangDB_O(SDList, ProcName, Sys) { return getDB(SDList, ProcName, "O", Sys, "http://localhost:49325/ZHONGLANGWXAPP/WEB/ZLSERVER.asmx/ZHONGLANGDBQueryOne"); }
function getZhongLangDB_Q(SDList, ProcName, Sys) { return getDB(SDList, ProcName, "Q", Sys, "http://localhost:49325//ZHONGLANGWXAPP/WEB/ZLSERVER.asmx/ZHONGLANGDBQueryToStr"); }
function getZhongLangDB_E(SDList, ProcName, Sys) { return getDB(SDList, ProcName, "E", Sys, "http://localhost:49325//ZHONGLANGWXAPP/WEB/ZLSERVER.asmx/ZHONGLANGDBExec"); }
//=====具体执行
var iWEBDBOPT = 0;  
function getDB(SDList,ProcName,ObjType,Sys,ObjUrl) {  
   var vPRAME = WEBDB_PRAME(ProcName, SDList, Sys);
   var vBACK = vPRAME;
  $.ajax({type:"POST",url: ObjUrl,data:{strJsonInfo:vPRAME },dataType:"text",async:false,
      success: function (data) { 
      if (ObjType == "O" || ObjType == "E"){ vBACK = WEBDB_ONE(data);}
      if (ObjType == "Q"){vBACK = WEBDB_ROWS(data);}   
      }, error: function () { 
      if (iWEBDBOPT <= 5 ){ //5次超时容错 
        iWEBDBOPT ++;
        getDB(SDList,ProcName,ObjType,ObjUrl);}
      else{alert('服务请求未响应,请重试！');vBACK = "";} 
    } 
   }); 
  return vBACK;   
}  
//=============================================================================== 
//=====参数拼接  
function WEBDB_PRAME (strProcName,arrProcPrame,strSys) { 
  var strBack = "" ; 
  for (var i = 0; i < arrProcPrame.length; i++) {
      var vOne = arrProcPrame[i].split(":");
      var vValue = escape(vOne[1]);//.replace("$", "&%^&").replace(":", "&^%&");
      strBack += (i == 0 ? "" : "$") + vOne[0] + ":" + vValue;
  }
  return strSys+"$"+strProcName + (strBack == "" ? "" : ("$" + strBack));
}  
//=====提取返回
function WEBDB_ONE(strin) {
  if (strin == undefined || strin=="undefined")  { return ""; }
  if (strin.length>2 && strin.substring(0,2)=="[{"){ return strin; } //未加格式的字符串
  var st_string='http://tempuri.org/">';
  var end_string="</string>";
  var in_str=strin;
  var start=in_str.indexOf(st_string)
  if (start<0){ return ''; }
  else{var start_index=start+st_string.length;
       var end_index=in_str.indexOf(end_string);
       var sub_string=in_str.slice(start_index,end_index);
       return sub_string;  }
} 
//=====提取多条  eg vdata[0].id 
function WEBDB_ROWS (strin) { 
  var strBack = WEBDB_ONE(strin); 
  if(strBack.length==0){return ''};
  var jsion=eval('(' + strBack + ')')
  return jsion; 
} 
//=============================================================================== 

